package metu.tespit.session.util;

import java.util.List;

import javax.persistence.EntityManager;

import metu.tespit.entitiy.accountManagement.User;
import metu.tespit.entity.course.ProjectDocument;
import metu.tespit.entity.course.ProjectTeam;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.security.Identity;

/**
 * @created Jun 9, 2012
 */
@Name("myTeam")
public class MyTeam {

	@In
	EntityManager entityManager;
	
	@In
	Identity identity;
	
	public boolean isMyTeam(Long a){
		User us=(User)entityManager.createQuery("Select u from User u where u.username=:usnam").setParameter("usnam", identity.getCredentials().getUsername()).getSingleResult();
		ProjectTeam pt = us.getProjectTeam();
		
		ProjectTeam pt2=(ProjectTeam)entityManager.createQuery("Select p from ProjectTeam p where p.id=:id").setParameter("id", a).getSingleResult();
		
		return pt!=pt2;
	}
	
}
